(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var AppClass = function () {
	function AppClass() {
		_classCallCheck(this, AppClass);

		this._eventContext = null;
		this._loadingPanel = null;
		this._pages = [];
		this._routes = [];
		this._user = null;
	}

	_createClass(AppClass, [{
		key: "login",
		value: function login(user) {
			this._user = Object.assign({}, user);
		}
	}, {
		key: "crudGridInstance",
		value: function crudGridInstance() {
			return $(".crud-grid").dxDataGrid("instance");
		}
	}, {
		key: "getFormInstance",
		value: function getFormInstance() {
			return $("#form").dxForm("instance");
		}
	}, {
		key: "getEventContext",
		value: function getEventContext() {
			return this._eventContext;
		}
	}, {
		key: "setEventContext",
		value: function setEventContext(v) {
			this._eventContext = v;
		}
	}, {
		key: "showLoading",
		value: function showLoading(message) {
			message = message || '正在加载...';

			this._loadingPanel = $("#loadpanel").dxLoadPanel({
				shadingColor: "rgba(0,0,0,0.4)",
				position: { of: "body" },
				visible: true,
				showIndicator: true,
				showPane: true,
				shading: true,
				closeOnOutsideClick: false,
				message: message
			}).dxLoadPanel("instance");
		}
	}, {
		key: "hideLoading",
		value: function hideLoading() {
			if (this._loadingPanel !== null) {
				this._loadingPanel.hide();
				this._loadingPanel = null;
			}
		}
	}, {
		key: "registerCrud",
		value: function registerCrud(opt) {
			this.pages.push(opt);
		}
	}, {
		key: "registerRoute",
		value: function registerRoute(opt) {
			this.routes.push(opt);
		}
	}, {
		key: "pages",
		get: function get() {
			return this._pages;
		}
	}, {
		key: "routes",
		get: function get() {
			return this._routes;
		}
	}, {
		key: "user",
		get: function get() {
			return this._user;
		}
	}]);

	return AppClass;
}();

var App = exports.App = new AppClass();


},{}],2:[function(require,module,exports){
'use strict';

var _app = require('./app');

var _util = require('./util');

var _util2 = _interopRequireDefault(_util);

var _page = require('./page');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_app.App.registerCrud({
	route: 'good', //路由名称
	url: $.config('apiUrl') + 'good',
	title: '商品&服务项目', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'name',
		caption: '商品名称'
	}, {
		dataField: 'code',
		caption: '商品编码',
		sortOrder: 'asc'
		// sortIndex:'code',
		// sortingMethod:function(a,b){
		// 	return a<b
		// }
	}, {
		dataField: 'categoryId',
		caption: '商品分类'
	}, {
		dataField: 'price',
		caption: '商品价格'
	}, {
		dataField: 'serviceTime',
		caption: '服务时间'
	}, {
		dataField: 'projectTypeId',
		caption: '项目类型'
	}, {
		dataField: 'site.name',
		caption: '场地类型'
	}, {
		dataField: 'jobId',
		caption: '工种' //名称
	}, {
		dataField: 'applySex',
		caption: '适用性别',
		cellTemplate: function cellTemplate(e, d) {
			var text = '';
			switch (d.data.applySex) {
				case '':
					text = '未指定';break;
				case 1:
					text = '男';break;
				case 2:
					text = '女';break;
			}
			$(e).text(text);
		}
	}, {
		dataField: 'shortName',
		caption: '商品简称'
	}, {
		dataField: 'plu',
		caption: '拼音助词码'
	}, {
		dataField: 'scanCode',
		caption: '条码'
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/good/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));

			return true;
		},
		items: [{
			dataField: "name",
			validationRules: [{ type: "required" }],
			label: { text: '商品名称' //名称
			} }, {
			dataField: 'code',
			validationRules: [{ type: "required" }],
			label: { text: '商品编码' }

		}, {
			dataField: "categoryId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'good-category?_no_page=1'),
				showClearButton: true,
				placeholder: "商品分类",
				searchEnabled: true,
				valueExpr: 'id',
				noDataText: '没有请求到商品分类数据',
				itemTemplate: function itemTemplate(data, index, $el) {
					if (data) {
						$("<span>" + data.name + "</span>").appendTo($el);
					}
				},
				displayExpr: function displayExpr(data) {
					return data ? data.name : "";
				}
			},
			label: { text: '商品分类' }
		}, {
			dataField: "price",
			editorType: 'dxNumberBox',
			label: { text: '商品价格' }
		}, {
			dataField: "serviceTime",
			editorType: 'dxNumberBox',
			label: { text: '服务时间' }
		}, {
			dataField: "projectTypeId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'project-type?_no_page=1'),
				showClearButton: true,
				placeholder: "项目类型",
				searchEnabled: true,
				valueExpr: 'id',
				noDataText: '没有请求到项目类型数据',
				itemTemplate: function itemTemplate(data, index, $el) {
					if (data) {
						$("<span>" + data.name + "</span>").appendTo($el);
					}
				},
				displayExpr: function displayExpr(data) {
					return data ? data.name : "";
				}
			},
			label: { text: '项目类型' //名称
			} }, {
			dataField: "siteId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'site?_no_page=1'),
				showClearButton: true,
				placeholder: "场地类型",
				searchEnabled: true,
				valueExpr: 'id',
				noDataText: '没有请求到场地类型数据',
				itemTemplate: function itemTemplate(data, index, $el) {
					if (data) {
						$("<span>" + data.name + "</span>").appendTo($el);
					}
				},
				displayExpr: function displayExpr(data) {
					return data ? data.name : "";
				}
			},
			label: { text: '场地类型' //名称
			} }, {
			dataField: "jobId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'job?_no_page=1'),
				showClearButton: true,
				placeholder: "工种",
				searchEnabled: true,
				valueExpr: 'id',
				noDataText: '没有请求到工种数据',
				itemTemplate: function itemTemplate(data, index, $el) {
					if (data) {
						$("<span>" + data.name + "</span>").appendTo($el);
					}
				},
				displayExpr: function displayExpr(data) {
					return data ? data.name : "";
				}
			},
			label: { text: '工种' //名称
			} }, {
			dataField: "applySex",
			label: { text: '适用性别' }, //名称
			editorType: "dxSelectBox",
			editorOptions: {
				displayExpr: 'name',
				valueExpr: 'value',
				dataSource: [{ name: '男性', value: 1 }, { name: '女性', value: 2 }, { name: '未指定', value: '' }]
			}
		}, {
			dataField: "shortName",
			label: { text: '商品简称' //
			} }, {
			dataField: "plu",
			label: { text: '拼音助词码' //名称
			} }, {
			dataField: "scanCode",
			label: { text: '条码' //名称
			} }]
	}
});

_app.App.registerCrud({
	route: 'job', //路由名称
	url: $.config('apiUrl') + 'job',
	title: '工种', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'code',
		caption: '工种编号'
	}, {
		dataField: 'name',
		caption: '工种名称'
	}, {
		dataField: 'shiftsName',
		caption: '所选班次'
	}, {
		dataField: 'rolesName',
		caption: '权限'
	},
	//  {
	// 	dataField: 'shiftOrder',
	// 	caption: '轮班顺序'
	// }, {
	// 	dataField: 'workTime',
	// 	caption: '作息时间'
	// }, {
	// 	dataField: 'scrollTime',
	// 	caption: '滚动时间'
	// }, {
	// 	dataField: 'dateCount',
	// 	caption: '可预约天数'
	// }, {
	// 	dataField: 'createdAt',
	// 	caption: '创建时间'//名称
	// },
	{
		dataField: 'isShow',
		caption: '在前台显示',
		cellTemplate: function cellTemplate(ele, da) {
			$(ele).text(da.data.isShow ? '是' : '否');
		}
	},
	// {
	// 	dataField: 'updatedAt',
	// 	caption: '修改时间'
	// },
	//	{
	//		dataField: 'updaterId',
	//		caption: '修改人'
	//	},
	{
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/job/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeDataShow: function beforeDataShow(data) {
			var arr = data.jobShifts.sort(function (a, b) {
				return a.sort - b.sort;
			});
			if (arr.length) {
				var ay = [];
				$(arr).each(function (index, item) {
					ay.push(item.shiftId);
				});
				data.jobShifts = ay;
			}
			if (data.roles.length) {
				var ar = [];
				$.each(data.roles, function (index, item) {
					ar.push(item.id);
				});
				data.roles = ar;
			} else {
				data.roles = [];
			}
			return data;
		},
		beforeDataSubmit: function beforeDataSubmit(data) {
			if (data.jobShifts.length) {
				var ar = [];
				$(data.jobShifts).each(function (index, item) {
					ar.push({
						shiftId: item,
						sort: index
					});
				});
				data.jobShifts = ar;
			}
			if (data.roles.length) {
				var arr = [];
				$.each(data.roles, function (index, item) {
					arr.push({ id: item });
				});
				data.roles = arr;
			}
			data.isShow = data.isShow ? 1 : 0;
			return data;
		},
		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));
			return true;
		},
		items: [{
			dataField: "code",
			validationRules: [{ type: "required" }],
			label: { text: '工种编号' //名称
			} }, {
			dataField: "name",
			validationRules: [{ type: "required" }],
			label: { text: '工种名称' //名称
			} },
		//  {
		// 	dataField: "jobShifts",
		// 	name:'jobShiftsshow',
		// 	validationRules: [{ type: "required" }],
		// 	editorType: 'dxTagBox',
		// 	display:false,
		// 	editorOptions: {
		// 		deferRendering: false,
		// 		dataSource: Util.crudStore($.config('apiUrl') + 'shift?_no_page=1'),
		// 		showClearButton: true,
		// 		placeholder: "所选班次",
		// 		searchEnabled: true,
		// 		valueExpr: 'id',
		// 		displayExpr:'name',
		// 		noDataText: '没有请求到所选班次数据'
		// 	},
		// 	label: { text: '所选班次' }//名称
		// }, 
		{
			dataField: "jobShifts",
			name: 'jobShiftshidden',
			editorType: 'dxTagBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'shift?_no_page=1'),
				showClearButton: true,
				placeholder: "所选班次",
				searchEnabled: true,
				valueExpr: 'id',
				displayExpr: 'name',
				noDataText: '没有请求到所选班次数据'
			},
			label: { text: '所选班次' //名称
			} }, {
			dataField: 'isShow',
			label: { text: '在前台显示' },
			editorType: 'dxCheckBox',
			editorOptions: {
				value: false
				// onValueChanged:function(e){
				// 	let value = e.value;
				// 	console.log($('#form').dxForm('instance').getEditor('jobShiftshidden'))
				// 	if(value){
				// 	$('#form').dxForm('instance').getEditor('jobShiftshidden').option('display',false)
				// 	$('#form').dxForm('instance').getEditor('jobShiftsshow').option('display',true)
				// 	}else{
				// 		$('#form').dxForm('instance').getEditor('jobShiftshidden').option('display',true)
				// 		$('#form').dxForm('instance').getEditor('jobShiftsshow').option('display',false)	
				// 	}
				// }
			}
		}, {
			dataField: "shiftOrder",
			label: { text: '轮班顺序' //名称
			} }, {
			dataField: "workTime",
			editorType: 'dxDateBox',
			label: { text: '作息时间' }
		}, {
			dataField: "scrollTime",
			label: { text: '滚动时间' }
		}, {
			dataField: "dateCount",
			editorType: 'dxNumberBox',
			label: { text: '可预约天数' }
		}, {
			dataField: 'roles',
			label: { text: '权限' },
			editorType: 'dxTagBox',
			editorOptions: {
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'role?_no_page=1'),
				displayExpr: 'name',
				valueExpr: 'id',
				showClearButton: true,
				placeholder: "权限选择",
				deferRendering: false
			}
		}]
	}
});

_app.App.registerCrud({
	route: 'shift', //路由名称
	url: $.config('apiUrl') + 'shift',
	title: '班次', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'code',
		caption: '班次编号'
	}, {
		dataField: 'name',
		caption: '班次名称'
	}, {
		dataField: 'startAt',
		caption: '开始时间',
		cellTemplate: function cellTemplate(c, data) {
			c.text(moment(data.value).format("HH:mm"));
		}
	}, {
		dataField: 'closeAt',
		caption: '结束时间',
		cellTemplate: function cellTemplate(c, data) {
			c.text(moment(data.value).format("HH:mm"));
		}
	}, {
		dataField: 'minCount',
		caption: '最小人数'
	}, {
		dataField: 'maxCount',
		caption: '最大人数'
	}, {
		dataField: 'creatorId',
		caption: '创建人' //名称
	}, {
		dataField: 'createdAt',
		caption: '创建时间'
	}, {
		dataField: 'updaterId',
		caption: '修改人'
	}, {
		dataField: 'updatedAt',
		caption: '修改时间'
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/shift/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));

			return true;
		},
		items: [{
			dataField: "code",
			validationRules: [{ type: "required" }],
			label: { text: '班次编号' //名称
			} }, {
			dataField: "name",
			validationRules: [{ type: "required" }],
			label: { text: '班次名称' //名称
			} }, {
			dataField: "startAt",
			validationRules: [{ type: "required" }],
			editorType: 'dxDateBox',
			editorOptions: {
				type: 'time',
				displayFormat: 'HH:mm:ss'
			},
			label: { text: '开始时间' //名称
			} }, {
			dataField: "closeAt",
			validationRules: [{ type: "required" }],
			editorType: 'dxDateBox',
			editorOptions: {
				type: 'time',
				displayFormat: 'HH:mm:ss'
			},
			label: { text: '结束时间' //名称
			} }, {
			dataField: "minCount",
			editorType: 'dxNumberBox',
			label: { text: '最小人数' //名称
			} }, {
			dataField: "maxCount",
			editorType: 'dxNumberBox',
			label: { text: '最大人数' //名称
			}
			//		,{
			//			dataField: "creatorId",
			//			label: { text: '创建人' }//名称
			//		},{
			//			dataField: "createdAt",
			//			editorType: 'dxDateBox',
			//			label: { text: '创建时间' }//名称
			//		},{
			//			dataField: 'updaterId',
			//			label: { text: '修改人' },
			//			
			//		}, {
			//			dataField: "updatedAt",
			//			editorType: 'dxDateBox',
			//			label: { text: '修改时间' },
			//		}
		}]
	}
});

var postForm = function postForm(url, data) {
	_util2.default.postForm(url, data).then(function (res) {
		if (res.data === 'success') {
			new DevExpress.ui.notify({ message: '操作成功' }, 'success', 1500);
			_app.App.crudGridInstance().option('dataSource').load();
			$('#popups').dxPopup('instance').option('visible', false);
		} else {
			new DevExpress.ui.notify({ message: '操作失败:' + res.errmsg }, 'warning', 1500);
		}
	});
};
var once_employee = false;
var dialogshow = function dialogshow(id, type) {
	$('#popups').html('');
	var options = {};
	var html = '<div class="leavebox" style="padding-bottom:10px"></div><div class="leavebutton"></div>';
	var methods = function methods() {
		// DevExpress.ui.dialog.confirm('请确认操作','提示').done(result=>{
		// 	if(result){
		var dialogform = $('#popups').dxPopup('instance').content().find('.leavebox');
		if (type) {
			dialogform = dialogform.dxForm('instance').option('formData');
			for (var item in dialogform) {
				dialogform[item] = new Date(dialogform[item]).getTime();
			};
			if (dialogform.start > dialogform.end) {
				return new DevExpress.ui.dialog.alert('结束时间应大于或等于开始时间');
			} else {
				dialogform.employeeId = id;
				postForm($.config('apiUrl') + 'employee/leave', dialogform);
			}
		} else {
			dialogform = dialogform.dxDataGrid('instance').getSelectedRowsData();
			if (dialogform.length) {
				var arr = [];$(dialogform).each(function (index, item) {
					arr.push(item.id);
				});
				postForm($.config('apiUrl') + 'employee/leave/cancel', arr);
			} else {
				new DevExpress.ui.dialog.alert('请先选择要取消的请假');
			}
		};
		// }
		// })
	};
	var formbutton = function formbutton(el) {
		el.find('.leavebutton').dxToolbar({
			items: [{
				location: 'after',
				widget: 'dxButton',
				options: {
					type: 'success',
					text: '提交',
					onClick: methods
				}
			}, {
				location: 'after',
				widget: 'dxButton',
				options: {
					type: 'success',
					text: '取消',
					onClick: function onClick() {
						$('#popups').dxPopup('instance').option('visible', false);
					}
				}
			}]
		});
	};
	if (type) {
		var now = moment().add(1, 'days');
		console.log(now);
		options = {
			title: '请假',
			width: '30%',
			visible: true,
			height: 'auto',
			contentTemplate: function contentTemplate(ele) {
				$(ele).append(html);
				$(ele).find('.leavebox').dxForm({
					formData: { start: new Date(), end: new Date() },
					colCount: 1,
					items: [{
						label: { text: '开始时间' },
						dataField: 'start',
						validationRules: [{ type: 'required' }],
						editorType: 'dxDateBox',
						eidtorOptions: {
							value: now,
							type: 'date',
							displayFormat: 'yyyy-MM-dd',
							dateSerializationFormat: "yyyy-MM-dd"
						}
					}, {
						label: { text: '结束时间' },
						dataField: 'end',
						validationRules: [{ type: 'required' }],
						editorType: 'dxDateBox',
						eidtorOptions: {
							value: now,
							type: 'date',
							displayFormat: 'yyyy-MM-dd',
							dateSerializationFormat: "yyyy-MM-dd"
						}
					}]
				});
				formbutton($(ele));
			}
		};
	} else {
		options = {
			title: '取消请假',
			width: '40%',
			visible: true,
			height: 'auto',
			contentTemplate: function contentTemplate(ele) {
				$(ele).append(html);
				$.get($.config('apiUrl') + 'employee/leave/list/' + id).then(function (res) {
					$(res.data).each(function (index, item) {
						item.end = moment(item.end).format('YYYY-MM-DD');
						item.start = moment(item.start).format('YYYY-MM-DD');
					});
					$(ele).find('.leavebox').dxDataGrid({
						dataSource: res.data || [],
						allowColumnResizing: true,
						selection: {
							mode: "multiple",
							showCheckBoxesMode: 'always',
							selectAllMode: 'page'
						},
						remoteOperations: true,
						paging: {
							pageSize: 10,
							pageIndex: 0
						},
						columns: [{
							caption: '开始时间',
							dataField: 'start'
						}, {
							caption: '结束时间',
							dataField: 'end'
						}]
					});
				});
				formbutton($(ele));
			}
		};
	}
	$('#popups').dxPopup(options);
};

var showSkill = function showSkill(data) {
	$('#popups').html();
	var leaveEle = $('#popups').dxPopup({
		visible: true,
		title: '批量设置员工技能',
		width: '60%',
		height: 'auto',
		contentTemplate: function contentTemplate(e) {
			var html = '<div class="leavebox" style="margin-bottom:10px"></div><div class="leavebutton"></div>';
			$(e).append(html);
			var selection = [];
			$(e).find('.leavebox').dxTagBox({
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'good?_no_page=1'),
				deferRendering: true,
				valueExpr: 'id',
				displayExpr: 'name',
				placeholder: '请选择员工技能',
				onValueChanged: function onValueChanged(e) {
					selection = e.value;
				}
			});

			$(e).find('.leavebutton').dxToolbar({
				items: [{
					location: 'after',
					widget: 'dxButton',
					options: {
						type: 'success',
						text: '提交',
						onClick: function onClick() {
							var form = {
								employees: [],
								goods: selection
							};
							data.forEach(function (item) {
								form.employees.push(item.id);
							});
							postForm($.config('apiUrl') + "employee/batch-assign-good", form);
						}
					}
				}, {
					location: 'after',
					widget: 'dxButton',
					options: {
						type: 'success',
						text: '取消',
						onClick: function onClick() {
							$('#popups').dxPopup('instance').option('visible', false);
						}
					}
				}]
			});
		}
	});
};

_app.App.registerCrud({
	route: 'employee', //路由名称
	url: $.config('apiUrl') + 'employee',
	title: '员工档案', //分页标题
	capable: {
		create: true
	},
	toolbar: {
		items: ['create', {
			widget: 'dxButton',
			location: 'before',
			options: {
				text: '批量设置员工技能',
				onClick: function onClick() {
					var data = _app.App.crudGridInstance().getSelectedRowsData();
					if (data.length === 0) {
						return new DevExpress.ui.dialog.alert('请选择员工');
					}
					showSkill(data);
				}
			}
		}]
	},
	columns: [{
		dataField: 'code',
		caption: '员工编号',
		sortOrder: 'asc'
	}, {
		dataField: 'name',
		caption: '员工名称'
	}, {
		dataField: 'sex',
		caption: '性别',
		cellTemplate: function cellTemplate(e, d) {
			var sex = '未设置';
			if (d.value === 1) {
				sex = '男';
			};
			if (d.value === 2) {
				sex = '女';
			};
			$(e).text(sex);
		}
	}, {
		dataField: 'jobId',
		caption: '工种',
		cellTemplate: function cellTemplate(e, d) {
			$(e).text(d.data.job.code + '-' + d.data.job.name);
		}
	}, {
		dataField: 'laborRelationId',
		caption: '劳务关系',
		cellTemplate: function cellTemplate(e, d) {
			$(e).text(d.data.laborRelation.name);
		}
	}, {
		dataField: 'isWork',
		caption: '是否在职',
		cellTemplate: function cellTemplate(e, d) {
			$(e).text(d.value ? '是' : '否');
		}
	}, {
		dataField: 'goodsName',
		caption: '员工技能'

	}, {
		dataField: 'password',
		caption: '员工密码'
	}, {
		dataField: 'cardId',
		caption: '卡ID' //名称
	}, {
		dataField: 'shopCode',
		caption: '门店号'
	}, {
		dataField: 'id',
		caption: '请假管理',
		cellTemplate: function cellTemplate(c, d) {
			var html = '<span class="userManage"><a class="leave">请假</a><b>/</b><a class="cancelleave" title="取消请假">取消请假</a></span>';
			$(c).html(html);
			var id = d.data.id;
			$(c).find('a.leave').click(function (e) {
				dialogshow(id, true);
			});
			$(c).find('a.cancelleave').click(function (e) {
				dialogshow(id, false);
			});
		}
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/employee/edit/{{id}}'
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeDataShow: function beforeDataShow(data) {
			once_employee = false;
			if (data.goods.length) {
				var arr = [];
				$.each(data.goods, function (index, item) {
					arr.push(item.id);
				});
				data.goods = arr;
			}
			return data;
		},
		beforeDataSubmit: function beforeDataSubmit(data) {
			if (data.goods) {
				var arr = [];
				$.each(data.goods, function (index, item) {
					arr.push({ id: item });
				});
				data.goods = arr;
			}
			return data;
		},

		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));

			return true;
		},
		items: [{
			dataField: "code",
			validationRules: [{ type: "required" }],
			label: { text: '员工编号' //名称
			} }, {
			dataField: "name",
			validationRules: [{ type: "required" }],
			label: { text: '员工名称' //名称
			} }, {
			dataField: "sex",
			validationRules: [{ type: "required" }],
			label: { text: '性别' }, //名称
			editorType: "dxSelectBox",
			editorOptions: {
				displayExpr: 'name',
				valueExpr: 'value',
				dataSource: [{ name: '男性', value: 1 }, { name: '女性', value: 2 }, { name: '未指定', value: '' }]
			}
		}, {
			dataField: "jobId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'job?_no_page=1'),
				showClearButton: true,
				placeholder: "工种",
				searchEnabled: true,
				valueExpr: 'id',
				displayExpr: 'name',
				noDataText: '没有请求到工种数据',
				onValueChanged: function onValueChanged(e) {
					var value = e.value;
					var instance = $('select[name="goods"]').parents('.dx-tagbox').dxTagBox('instance');
					$.get($.config('apiUrl') + 'good?_no_page=1').then(function (res) {
						var data = res.data.filter(function (item) {
							return item.jobId == value;
						});
						instance.option('dataSource', data);
						if (once_employee) {
							_app.App.getFormInstance().option('formData.goods', []);
						}
						once_employee = true;
					});
				}
			},
			label: { text: '工种' //名称
			} }, {
			dataField: "laborRelationId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'labor-relation?_no_page=1'),
				showClearButton: true,
				placeholder: "劳务关系",
				searchEnabled: true,
				valueExpr: 'id',
				noDataText: '没有请求到劳务关系数据',
				itemTemplate: function itemTemplate(data, index, $el) {
					if (data) {
						$("<span>" + data.name + "</span>").appendTo($el);
					}
				},
				displayExpr: function displayExpr(data) {
					return data ? data.name : "";
				}
			},
			label: { text: '劳务关系' //名称
			} }, {
			dataField: "isWork",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				valueExpr: 'value',
				displayExpr: 'name',
				dataSource: [{ name: '是', value: 1 }, { name: '否', value: 0 }],
				value: 0
			},
			label: { text: '是否在职' //名称
			} }, {
			dataField: "goods",
			label: { text: '员工技能' },
			editorType: 'dxTagBox',
			editorOptions: {
				showSelectionControls: true,
				deferRendering: false,
				dataSource: [],
				searchEnabled: true,
				valueExpr: 'id',
				displayExpr: 'name'
			}
		}, {
			dataField: 'password',
			validationRules: [{ type: "required" }],
			label: { text: '员工密码' }

		}, {
			dataField: "cardId",
			label: { text: '卡ID' }

		}, {
			dataField: "shopCode",
			validationRules: [{ type: "required" }],
			editorType: 'dxNumberBox',
			label: { text: '门店号' }

		}]
	}
});

_app.App.registerCrud({
	route: 'room', //路由名称
	url: $.config('apiUrl') + 'room',
	title: '场地管理', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'number',
		caption: '编号',
		sortOrder: 'asc'
	}, {
		dataField: 'name',
		caption: '场地名称'
	}, {
		dataField: 'site.name',
		caption: '场地类型'
	}, {
		dataField: 'max',
		caption: '容纳人数'
	}, {
		dataField: 'remark',
		caption: '备注' //名称
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/room/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));

			return true;
		},
		items: [{
			dataField: "number",
			validationRules: [{ type: "required" }],
			label: { text: '编号' //名称
			} }, {
			dataField: "name",
			validationRules: [{ type: "required" }],
			label: { text: '场地名称' //名称
			} }, {
			dataField: "siteId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'site?_no_page=1'),
				showClearButton: true,
				placeholder: "场地类型",
				searchEnabled: true,
				valueExpr: 'id',
				noDataText: '没有请求到场地类型数据',
				itemTemplate: function itemTemplate(data, index, $el) {
					if (data) {
						$("<span>" + data.name + "</span>").appendTo($el);
					}
				},
				displayExpr: function displayExpr(data) {
					return data ? data.name : "";
				}
			},
			label: { text: '场地类型' //名称
			} }, {
			dataField: "roomStatusId",
			validationRules: [{ type: "required" }],
			editorType: 'dxSelectBox',
			editorOptions: {
				deferRendering: false,
				dataSource: _util2.default.crudStore($.config('apiUrl') + 'room-type?_no_page=1'),
				showClearButton: true,
				placeholder: "请选择房间状态",
				searchEnabled: true,
				valueExpr: 'id',
				noDataText: '没有请求到房间状态数据',
				itemTemplate: function itemTemplate(data, index, $el) {
					if (data) {
						$("<span>" + data.name + "</span>").appendTo($el);
					}
				},
				displayExpr: function displayExpr(data) {
					return data ? data.name : "";
				}
			},
			label: { text: '房间状态' //名称
			} }, {
			dataField: "max",
			validationRules: [{ type: "required" }],
			editorType: 'dxNumberBox',
			label: { text: '容纳人数' //名称
			} }, {
			dataField: 'remark',
			label: { text: '备注' }

		}]
	}
});

_app.App.registerCrud({
	route: 'boahandcardrd', //路由名称
	url: $.config('apiUrl') + 'handcard',
	title: '手牌管理', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'number',
		caption: '编号'
	}, {
		dataField: 'name',
		caption: '名称'
	}, {
		dataField: 'cardId',
		caption: '卡ID'
	}, {
		dataField: 'price',
		caption: '价格'
	}, {
		dataField: 'kidPrice',
		caption: '儿童价格' //名称
	}, {
		dataField: 'coord',
		caption: '屏幕显示坐标'
	}, {
		dataField: 'leastConsume',
		caption: '最底消费'
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/boahandcardrd/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));

			return true;
		},
		items: [{
			dataField: "number",
			validationRules: [{ type: "required" }],
			label: { text: '编号' //名称
			} }, {
			dataField: "name",
			validationRules: [{ type: "required" }],
			label: { text: '名称' //名称
			} }, {
			dataField: "cardId",
			label: { text: '卡ID' //名称
			} }, {
			dataField: "price",
			editorType: 'dxNumberBox',
			label: { text: '价格' //名称
			} }, {
			dataField: 'kidPrice',
			editorType: 'dxNumberBox',
			label: { text: '儿童价格' }

		}, {
			dataField: "coord",
			editorType: 'dxNumberBox',
			label: { text: '屏幕显示坐标' }

		}, {
			dataField: "leastConsume",
			editorType: 'dxNumberBox',
			label: { text: '最底消费' }

		}]
	}
});


},{"./app":1,"./page":3,"./util":4}],3:[function(require,module,exports){
"use strict";

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Page = exports.Page = function () {
	function Page($container) {
		_classCallCheck(this, Page);

		this.$container = $container;
		this.$content = $container;
	}

	_createClass(Page, [{
		key: "crudLayout",
		value: function crudLayout(opt) {
			var data = Object.assign({ title: '未设置' }, opt),
			    html = "<div class=\"app-content-body \">\n\t\t  <div class=\"bg-light lter b-b wrapper-md hidden-print\">\n\t\t    <h1 class=\"m-n font-thin h3\">{{title}}</h1>\n\t\t  </div>\n\t\t  <div>\n\t\t    <div class=\"crud-container crud-reset\">\n\t\t    </div>\n\t\t  </div>\n\t\t</div>";

			this.$container.html(Mustache.render(html, data));
			this.$content = this.$container.find(".crud-container");

			return this;
		}
	}, {
		key: "content",
		get: function get() {
			return this.$content;
		}
	}]);

	return Page;
}();


},{}],4:[function(require,module,exports){
'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Util = function () {
	function Util() {
		_classCallCheck(this, Util);
	}

	_createClass(Util, [{
		key: 'formatXbm',
		value: function formatXbm(xbm) {
			if (xbm == '2') return '女';else if (xbm == '1') return '男';else return xbm;
		}
	}, {
		key: 'crudStore',
		value: function crudStore(url, options) {

			var SERVICE_URL = url;
			options = $.extend({
				onDataArrived: function onDataArrived(data) {
					return data;
				}
			}, options);

			return new DevExpress.data.CustomStore($.extend({}, options, {

				load: function load(loadOptions) {

					var u = new Url(SERVICE_URL);

					u.query._param = JSON.stringify(loadOptions);

					return $.getJSON(u).then(function (resp, status, xhr) {

						if (resp.success) {
							resp = {
								status: 'success',
								data: resp.items
							};
						} else {
							resp = {
								status: 'success',
								totalCount: resp.totalCount,
								data: resp.data
							};
						}

						return options.onDataArrived(resp);
					});
				},

				byKey: function byKey(key) {
					var u = new Url(SERVICE_URL);
					u.path += "/" + encodeURIComponent(key);

					return $.getJSON(u).then(function (resp) {
						return resp;
					});
				},

				insert: function insert(values) {
					return $.post(SERVICE_URL, values).always(function (resp) {
						$.crudStoreResp = resp.responseJSON;
						return resp;
					});
				},

				update: function update(key, values) {
					var u = new Url(SERVICE_URL);
					u.path += "/" + encodeURIComponent(key);

					return $.ajax({
						url: u,
						method: "PUT",
						data: values
					}).always(function (resp) {
						$.crudStoreResp = resp.responseJSON;
						return resp;
					});
				},

				remove: function remove(key) {
					var u = new Url(SERVICE_URL);
					u.path += "/" + encodeURIComponent(key);

					return $.ajax({
						url: u,
						method: "DELETE"
					});
				}

			}));
		}
	}, {
		key: 'postForm',
		value: function postForm(url, data) {
			return $.ajax({
				url: url,
				data: JSON.stringify(data),
				contentType: "application/json",
				dataType: 'json',
				type: 'post'
			});
		}
	}]);

	return Util;
}();

exports.default = new Util();


},{}]},{},[2]);
